In-circuit programming of output voltage and output current characteristics of a PSR power supply

ABSTRACT

A primary-side regulation (PSR) controller integrated circuit includes a PSR CC/CV controller and a non-volatile shift register. An assembled power supply that includes the integrated circuit is in-circuit tested to determine errors in power supply output voltage and/or current. Programming information is determined and shifted into the shift register. During programming, the power supply regulates to a different output voltage, and the different voltage is used for shift register programming. After programming, the power supply operates in a normal mode so that the output voltage and current are within specification. The voltage and current to which the power supply regulates are set by some of the bits of the programming information. Other of the bits set error correction circuits of the PSR CC/CV controller such as a primary inductance variation compensation circuit, a line input voltage variation compensation circuit, an efficiency variation compensation circuit, and a cord resistance compensation circuit.

TECHNICAL FIELD

The present disclosure relates generally to primary-side regulation(PSR) power supplies and PSR controller integrated circuits.

BACKGROUND INFORMATION

FIG. 1 (Prior Art) is a block diagram of primary-side regulationconstant current/constant voltage (PSR CC/CV) flyback power supply 1. Analternating current (AC) 110-240 volt line voltage on input terminals 2and 3 is rectified by a full wave bridge rectifier 4 and an associatedsmoothing capacitor 5 so that a rectified and smoothed rough DC voltageis present between the first and second input nodes 6 and 7. The voltageon first input node 6 is also referred to in this document as the “inputline voltage” or “line input voltage” (VIN).

Power supply 1 operates by repeatedly closing and opening a switch. Inthe illustrated example, the switch is a bipolar transistor 8. Closingswitch 8 causes a primary current to flow from node 6, through a primary9 of a transformer 23, through switch 8, into terminal 10 of a PSR CC/CVcontroller integrated circuit 11, through another switch (not shown)inside the PSR CC/CV controller integrated circuit 11, and from theground terminal 12 of the PSR CC/CV controller integrated circuit 11 tothe second input node 7. When switch 8 is closed, the current that flowsthrough primary 9 causes energy to be stored in transformer 23. Whenswitch 8 is opened, the energy stored is transferred to the output ofthe power supply in the form of a pulse of current that flows through asecondary 13 of transformer 23 and through a diode 14. An outputcapacitor 15 is connected across output terminals 16 and 17 of the powersupply. The pulse of current charges capacitor 15. In steady stateoperation in the constant voltage (CV) mode, switch 8 is switched toopen and close rapidly and in such a manner that the output voltage VOUTon capacitor 15 remains substantially constant at a desired regulatedoutput voltage. The output voltage VOUT is related to the voltage VAUXacross an auxiliary winding 18. VAUX is divided by a voltage dividerincluding resistors 19 and 20 so that the voltage on the voltage dividertap 21 is sensed on an FB terminal 22 of PSR CC/CV controller integratedcircuit 11. PSR CC/CV controller integrated circuit 11 has an internalreference voltage generator that generates a reference voltage VREF.Controller integrated circuit 11 regulates VOUT to have the desiredregulated output voltage by keeping the voltage on FB terminal 22 equalto the internal reference voltage VREF.

The current IOUT being supplied from the output of the power supply isrelated to the current flowing through primary 9. In theconstant-current (CC) operating mode, the magnitude of the primarycurrent is detected by detecting the voltage across the switch (notshown) inside PSR CC/CV controller integrated circuit 11. This voltage,which is the product of the current flow in the switch and theresistance of the switch, is sensed and amplified by a current senseamplifier inside PSR CC/CV controller integrated circuit 11. The outputcurrent IOUT is regulated to a desired regulated output current bykeeping the peak voltage detected by the current sense amplifier equalto a reference voltage value VILIM.

In the example of FIG. 1, power supply 1 is a battery charger such as abattery charger usable to charge the rechargeable batteries of acellular telephone. The AC line in terminals 2 and 3 are typicallyplugged into a wall socket to receive alternative current (AC) 110-240VAC power. The two terminals 16 and 17 at the end of a cord are pluggedinto the cellular telephone. Initially, if the batteries in the cellulartelephone are discharged, then the battery charger operates in theconstant current (CC) mode and supplies charging current at theregulated current amount (in the present example, 1 ampere). Then, oncethe batteries have charged to the point that the output voltage VOUTreaches the desired regulated voltage (in the present example, 5 volts),the power supply 1 starts operating in the constant voltage (CV) mode.PSR CC/CV power supply 1 then regulates such that the output voltageVOUT stays at the desired regulated output voltage while the suppliedoutput current decreases.

FIG. 2 (Prior Art) is a graph of output voltage VOUT versus outputcurrent IOUT. Initially when PSR CC/CV power supply 1 is operating inthe CC mode, the output voltage and current operating point of the powersupply lies on line 24. The point migrates vertically up line 24 as thevoltage on the battery increases as the battery charges. When the pointreaches corner 25, the power supply transitions to the CV mode. Thepoint representing the output voltage and output current migrates to theleft along horizontal line 26.

The graph of FIG. 2 is, however, an idealization. In an actual PSR CC/CVpower supply, lines 24 and 26 are not followed. The output voltage andcurrent points may extend away from lines 24 and 26 so much that theactual power supply operating point is outside a specified permittedoperating range. In the example of FIG. 2, for the power supply to meeta particular specification and standard, the output current IOUT in theCC mode must be within plus or minus ten percent of the regulated outputcurrent of 1.0 amperes. Similarly, the output voltage VOUT in the CVmode must be within plus or minus five percent of the regulated outputvoltage of 5.0 volts.

There are many potential reasons that the actual power supply operatingpoint may be outside of the specified bounds. Different units of the PSRCC/CV controller integrated circuit may be affected in different ways bythe semiconductor manufacturing process used to make the integratedcircuits and by the process used to package the integrated circuits.U.S. Pat. No. 6,750,640 teaches that after controller integratedcircuits have been tested at “wafer sort”, that their operation fromunit to unit can be affected to different degrees by the packagingprocess. For example, U.S. Pat. No. 6,750,640 teaches that power supplycontroller chips can be trimmed or adjusted after “wafer sort” and afterpackaging at “final test” of the integrated circuits.

FIG. 3 (Prior Art) is a replication of FIG. 1 from U.S. Pat. No.6,750,640. At integrated circuit final test, programmable circuitconnections within the integrated circuit are programmed to trim oradjust certain functions of the power supply controller chip such asover voltage threshold, under voltage threshold, external current limit,maximum duty cycle and power supply enable/disable. Although the circuitof FIG. 3 is satisfactory in certain respects, it is undesirable and/orunsatisfactory in other ways. Circuitry outside the controllerintegrated circuit may have electrical characteristics that are seen todiffer, from power supply unit to power supply unit, such that thesedifferences cause different units of seemingly identical mass producedpower supplies to exhibit output voltage and output current operatingpoints outside of the specified limits of FIG. 2. For example, somemanufactured power supply units may operate along line 27 under certainoperating conditions (see FIG. 4), whereas other units may operate alongline 28 (see FIG. 4). Also, under some operating conditions, some powersupply units may operate along line 29. The mass produced transformersused to make the power supplies may, for example, have primaryinductances that vary from one transformer to the next. Also, massproduced power cords may have resistances that differ from each other.Such differing inductances and resistances may lead to differentmanufactured power supply units operating outside required bounds asillustrated in FIG. 4, even if the controller integrated circuit 11 isadjusted at final test. Moreover, it may be desired to use the samecontroller integrated circuit and power supply design but to attachdifferent power cords to different units of the power supply. Some unitsmay be made to have long cords, whereas other units may be made to haveshort cords. Regardless of such variations, it is desired that all theassembled power supplies supply power at the end terminals of the powercord that is within the specified five percent and ten percent boundsillustrated in FIG. 4.

SUMMARY

A novel primary-side regulation (PSR) controller integrated circuitincludes a PSR CC/CV controller and a non-volatile shift register. Anassembled power supply that includes the novel PSR CC/CV integratedcircuit is in-circuit tested to determine errors in output voltageand/or output current of the power supply. Programming information isthen determined. The integrated circuit is put into a program mode, andthe determined programming information is shifted into the integratedcircuit and into the non-volatile shift register. The programminginformation is then automatically programmed into the non-volatile shiftregister. During the program mode, the power supply regulates to eithera higher or lower voltage than it does in normal mode and this higher orlower voltage is used as a programming voltage to program thenon-volatile shift register. The type of non-volatile memory andparticular integrated circuit wafer manufacturing process determineswhether the programming voltage is higher or lower than the normal modevoltage.

After programming, when the assembled power supply is used and operatesin normal mode, the programming information in the non-volatile shiftregister sets or controls circuitry in the PSR CC/CV controllerintegrated circuit such that the output voltage and output current ofthe power supply are within specification. Some of the bits of theprogramming information set the voltage to which the output voltage isregulated. Other bits of the programming information set the current towhich the output current is regulated. Other bits of the programminginformation set or control error correction circuits of the PSR CC/CVcontroller such as a primary inductance variation compensation circuit,a line input voltage variation compensation circuit, an efficiencyvariation compensation circuit, and a cord resistance compensationcircuit.

Other structures and methods are described in the detailed descriptionbelow. This summary does not purport to define the invention. Theinvention is defined by the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, where like numerals indicate like components,illustrate embodiments of the invention.

FIG. 1 (prior art) is a diagram of a conventional PSR CC/CV powersupply.

FIG. 2 (prior art) is an idealized graph of output voltage VOUT versusoutput current IOUT for a PSR CC/CV power supply.

FIG. 3 (prior art) is a replication of FIG. 1 from U.S. Pat. No.6,750,640.

FIG. 4 (prior art) is a graph of output voltage VOUT versus outputcurrent IOUT for an assembled PSR CC/CV power supply.

FIG. 5 is a diagram of a system 200 in accordance with one novel aspect.

FIG. 6 is a more detailed circuit diagram of the PSR CC/CV controllerintegrated circuit 203 of FIG. 5.

FIG. 7 is a table that sets forth functions controlled by the variousbits of programming information shifted into the non-volatile shiftregister 204 of FIG. 6.

FIG. 8 is a diagram that illustrates one way that the programmableresistors of FIG. 6 can be realized.

FIG. 9 is a waveform diagram of signals in power supply 202 of FIG. 5.

FIG. 10 is a waveform diagram that illustrates a novel method of puttingPSR CC/CV controller integrated circuit 203 of FIG. 5 into the programmode, of serially shifting programming information into the non-volatileshift register, and then programming the programming information intothe non-volatile shift register.

FIG. 11 is a flowchart of a novel method of programming a PSR CC/CVcontroller integrated circuit.

FIG. 12 is a simplified circuit diagram of one way to realize a bit ofnon-volatile shift register 204 of FIG. 5.

FIG. 13 is a diagram that shows how IOUT increases with decreasing VOUTdue to an increase in efficiency in an actual assembled PSR CC/CV powersupply.

FIG. 14 is a circuit diagram of the efficiency variation compensationcircuit 238 (CC1) and of the line input voltage variation compensationcircuit 239 (CC2) of FIG. 6.

FIG. 15 shows the ramp up in primary current ILP in two conditions,where the two conditions lead to two different peak current values.

FIG. 16 is a circuit diagram of the cord resistance compensation circuit240 (CC3) of FIG. 6.

DETAILED DESCRIPTION

Reference will now be made in detail to some embodiments of theinvention, examples of which are illustrated in the accompanyingdrawings.

FIG. 5 is a diagram of a system 200 in accordance with one novel aspect.System 200 involves automatic test equipment (ATE) 201 and a powersupply 202. Power supply 202 is an assembled and operating primary-sideregulation constant current/constant voltage (PSR CC/CV) flyback batterycharger. In the illustrated example, power supply 202 is a populatedprinted circuit board of the power supply that is not yet covered withits plastic enclosure. The various nodes of the printed circuit boardare accessible for probing and testing.

Rather than just testing and/or programming a PSR controller integratedcircuit at “final test” of the integrated circuit as described in thebackground section of this patent document, novel PSR CC/CV controllerintegrated circuit 203 is a part of assembled power supply 202. Whilepower supply 202 operates, ATE 201 exercises the power supply andcollects information on how the power supply performs under differentoperating conditions. ATE 201 then uses the collected information todetermine what programming information (DATA) to load into a rewritablenon-volatile shift register 204 portion of integrated circuit 203. Toload the programming information, ATE puts integrated circuit 203 into aprogram mode by some mechanism. In the present example, ATE 201 drivesan unusually high voltage onto the FB feedback terminal 206 ofintegrated circuit 203. Because this high voltage is not a voltage thatwould ordinarily be on FB terminal 206 during normal power supplyoperation (not during program mode operation), PSR CC/CV controllercircuitry 217 of integrated circuit 203 detects the unusually highvoltage and in response enters the program mode. ATE 201 then seriallysupplies bits of the determined programming information (DATA) ontofeedback terminal FB 206 synchronously with the switching signal SW ofintegrated circuit 203 on SW terminal 205. The programming informationis shifted into non-volatile shift register 204.

In one embodiment, PSR CC/CV controller integrated circuit 203 includesa programming information readback capability usable to verify thatproper programming information was loaded into integrated circuit 203.Microcontroller terminal 232 is a bi-directional input/output terminal,and FB terminal 206 is also a bi-directional input/output terminal.Control logic of integrated circuit 203 includes logic that looks at thefirst bit received from ATE 201 and if the bit is a zero, thenintegrated circuit 203 remains in a write sub-mode of the program mode(integrated circuit 203 is written to in the program mode), whereas ifthe bit is a one, then integrated circuit 203 enters a read sub-mode ofthe program mode (information from integrated circuit 203 is read by ATE201) and shifts programming information out FB terminal 206 and ontoconductor 233. ATE 201 reads the information from conductor 233, andconfirms that proper programming information was shifted intonon-volatile shift register 204 during the write sub-mode.

Once the proper programming information is in non-volatile shiftregister 204, the programming information sets and adjusts variouselectrical output characteristics of power supply 202. In one example,the programming information (DATA) sets a desired regulation voltage atwhich integrated circuit 203 regulates the output voltage VOUT duringconstant voltage (CV) mode operation, and also sets a desired regulationcurrent at which integrated circuit 203 regulates the output currentIOUT during constant current (CC) mode operation. ATE 201 performs suchtesting and programming on unit after unit of assembled power supplies.By testing and programming at this “in-circuit” stage of manufacture ofthe power supplies, current/voltage points of operation outside ofspecified bounds due to variations in components of the power supplysuch as the transformer and the power cord can be compensated for suchthat all units after programming will operate within the specifiedbounds. The structure and operation of system 200 is described infurther detail below.

Operation in Normal Mode:

Assembled PSR CC/CV power supply 202 includes two AC input terminals 207and 208, a full wave bridge rectifier 209, and a smoothing capacitor210. An alternating current 110-240 volt (AC) line voltage on inputterminals 207 and 208 is rectified by rectifier 209 and capacitor 210 sothat a rectified and smoothed rough DC voltage is present between firstand second input nodes 211 and 212. The voltage on first input node 211is also referred to as the “input line voltage” or “line input voltage”(VIN). VIN is used to power programmable PSR CC/CV controller integratedcircuit 203. Power is received using a network involving resistor 213and capacitor 214 such that a voltage referred to here as VDD issupplied onto a VCC terminal 215 of integrated circuit 203. Groundpotential on input node 212 is supplied onto a ground terminal 216 ofintegrated circuit 203.

Assembled PSR CC/CV power supply 202 also includes a transformer 218, aswitch 219, components 220 and 221, two diodes 223 and 224, an outputcapacitor 225, and a power cord that terminates in two terminals 226 and227. The RCORD+ and RCORD− labels represent resistance of the powercord. Such resistances may, for example, be approximately 0.25 ohms.Transformer 218 includes a primary winding 228, a secondary winding 229,and an auxiliary winding 230.

FIG. 6 is a more detailed circuit diagram of PSR CC/CV controllerintegrated circuit 203 of FIG. 5. Integrated circuit 203 includes thenon-volatile shift register 204. The remainder of the circuitryillustrated in FIG. 6 is the PSR CC/CV controller 217 of FIG. 5.Integrated circuit 203 has four and only four terminals: FB terminal206, SW terminal 205, VDD terminal 215 and ground terminal 216.

FIG. 7 is a table that sets forth the functions controlled by thevarious bits DOUT [0:31] of programming information stored innon-volatile shift register 204.

FIG. 8 is a diagram that illustrates one way that the programmableresistors R1, R2 and R4 of FIG. 6 can be realized. An incoming four-bitdigital value on input leads 300 is decoded by 4:16 decoder 301 togenerate control signals C1-C16. Each one of control signals C1-C16controls a corresponding respective one of the various illustratedswitches to short out or switch in the associated resistors RS1-RS16between node 302 and 303. Resistor RS17 is always coupled into thecurrent path between nodes 302 and 303.

When operating in the constant voltage (CV) mode and in the normal mode(not the program mode), integrated circuit 203 causes an N-channeltransistor 400 (see FIG. 6) to be conductive. This allows current tobegin to flow from line input node 211 (see FIG. 5), through primarywinding 228, through switch 219, into SW terminal 205 of integratedcircuit 203, through N-channel transistor 400, to ground terminal 216 ofintegrated circuit 203, and to ground node 212.

FIG. 9 is a waveform diagram of signals in power supply 202. Thewaveform labeled ILP represents the current flowing through primarywinding 228. In response to a rising edge of PCLK, control logic 411(see FIG. 6) asserts the switch-on signal SWON high, thereby turning onN-channel transistor 400 at time T1. The primary current ILP ramps up asillustrated in FIG. 9.

The output voltage VOUT of the power supply is related to the voltageVAUX on auxiliary winding 230 during the off-time of switch 400. Thewaveform VAUX is illustrated in FIG. 9. Integrated circuit 203 regulatesoutput voltage VOUT by using the VAUX voltage detected through a voltagedivider of external resistors RFB1 and RFB2. The divided down VAUXvoltage on the tap of the voltage divider is detected on FB terminal206. When the power supply is in normal mode (not in program mode),signal PMB is high and signal PM is low. Switch 401 of FIG. 6 istherefore closed and switch 402 is open. The voltage on FB terminal 206is therefore supplied through switch 401 and onto node 403. Feedbacksampler 404 samples the voltage on node 403 each switching cycle at timeT3 (see FIG. 9) during the off-time of N-channel transistor 400 andsupplies the sampled voltage VFB onto node 405. Transconductance erroramplifier 406 generates an error signal based on a voltage differencebetween the voltage VFB on node 405 and a reference voltage VREF′ onnode 407. Due to capacitor 408, error amplifier 406 functions as anintegrator such that over time the relatively slowly varying voltageVCOMP decreases as the voltage VFB increases with respect to VREF′ fromcycle to cycle. Current sense amplifier 409 senses the voltage dropacross the on-resistance of N-channel transistor 400 during the on-timeof transistor 400. In FIG. 9, after time T1 when the primary current ILPbegins to ramp up, the current sense signal VCS also begins to ramp up.When the voltage VCS increases to the point that it reaches VCOMP,comparator 410 (see FIG. 6) trips and supplies a rising edge to controllogic 411. Control logic 411, in response to receiving either a risingedge from comparator 410 or from comparator 412, forces signal SWON lowand turns off N-channel transistor 400. The turning off of N-channeltransistor 400 is illustrated at time T2 in FIG. 9. The cutting off ofcurrent flow in primary winding 228 causes current to flow in secondarywinding 229 as illustrated in waveform ILS in FIG. 9. The ILS currentramps down as illustrated until it reaches zero. This operation isreferred to as “discontinuous mode” operation because there is an amountof time during the off-time of switch 219 when there is no current flowin the secondary winding 229. The switching cycle repeats on the nextrising edge of the clock signal PCLK. The control loop operates to keepthe N-channel transistor 400 conductive for a long enough amount of timethat the voltage VFB on node 405 is regulated to be equal to the voltageVREF′ on node 407. VREF′ is adjusted so that VOUT is regulated to thedesired voltage.

When operating in the constant current (CC) mode and in the normal mode(not the program mode), integrated circuit 203 also causes N-channeltransistor 400 to be switched on and off. As in the case of the CV mode,the rising edge of PCLK causes control logic 411 to assert signal SWONhigh, thereby making N-channel transistor 400 conductive at thebeginning of the switching cycle. Rather than N-channel transistor 400being turned off due to a rising edge output from comparator 410,however, the N-channel transistor 400 is turned off due to a rising edgeoutput from current limit comparator 412. During the on-time ofN-channel transistor 400, the signal VCS ramps up along with the primarycurrent waveform ILP illustrated in FIG. 9. Although voltage VCOMP ishigher than the voltage VCS, the voltage VCS reaches the voltage VILIMon node 413. Current limit comparator 412 therefore trips and supplies arising edge signal to control logic 411. Control logic 411 responds tothis rising edge by forcing SWON low and turning N-channel transistor400 off. Accordingly, rather than a rising edge from comparator 410causing N-channel transistor 400 to turn off as in the CV mode, a risingedge from current limit comparator 412 causes N-channel transistor 400to turn off in the CC mode. VILIM on node 413 is adjusted so that IOUTis regulated to the desired regulated current.

Operation in Program Mode:

FIG. 10 is a waveform diagram that illustrates a novel method of puttingPSR CC/CV controller integrated circuit 203 into the program mode, ofserially shifting programming information into the non-volatile shiftregister 204 of integrated circuit 203 while in the program mode, andthen programming the programming information into the non-volatile shiftregister 204 while in the program mode. Initially, the assembled powersupply 202 is operating in constant voltage mode and in normal mode, andis coupled to ATE 201 as illustrated in FIG. 1. In normal operation, thevoltage on FB terminal 206 of integrated circuit 203 is approximately2.5 volts. Microcontroller 231 is coupled to FB terminal 203 via outputterminal 232 and conductor 233. Microcontroller 231 does not driveconductor 233, but rather maintains its terminal 232 in a high-impedancestate so that the feedback voltage on terminal FB 206 is not affected bythe microcontroller.

Then, at time T4, microcontroller 231 drives its terminal 232 to fivevolts, thereby driving conductor 233 and terminal FB 206 of integratedcircuit 203 to five volts. This is illustrated in the upper waveformlabeled FB(PIN) in FIG. 10. This condition is detected by program modedetection circuitry 234 in FIG. 6. Signal PM is asserted high, andsignal PMB is asserted low. The assertion of signal PM high isrepresented by the low-to-high transition of the signal waveform PM inFIG. 10. When PM transitions high, switch 401 opens and decouples theterminal FB 206 from node 403, and switch 402 closes and couples node403 to an on-chip resistor voltage divider involving resistors R11 andR12. Whereas the external resistors RFB1 and RFB2 of FIG. 5 are sizedsuch that integrated circuit 203 operates in CV mode to regulate theoutput voltage VOUT to 5.0 volts and VAUX to a corresponding 15.0 volts,for example, the internal resistors R11 and R12 are sized such thatintegrated circuit 203 operates in CV mode to regulate the VOUT to avoltage higher than 5.0 volts. VAUX is therefore at a corresponding 17.0volts. The VAUX of 17.0 volts is referred to as the programming voltageVPP. Note that in each successive switching cycle illustrated in FIG.10, the VFB and VDD voltages increase until VDD (VDD is VAUX minus adiode voltage drop) reaches 17.0 volts.

Microcontroller 231, after driving FB terminal 206 to five volts andputting integrated circuit 203 into the program mode, uses the signal SWto time the driving of programming data across conductor 233 and onto FBterminal 206. ATE 201 receives the signal SW, and inverts it to form thesignal UCLK that is then received by microcontroller 231.Microcontroller 231 detects this signal UCLK and drives the first bit ofprogramming information onto conductor 233 in response to a low-to-hightransition of UCLK (this corresponds to a high-to-low transition of SW).This occurs roughly at time T5 in the waveform diagram of FIG. 10.

Upon entering the program mode, the signal PM as supplied to thenon-volatile shift register 204 in FIG. 6 is asserted high, therebyallowing DCLK (an inverted version of the switching signal SWON) to passthrough AND gate 235 and to cause BCLK to begin clocking. In FIG. 10,note that the first BCLK pulse occurs after entering the program modeafter time T4, and that this first pulse of BCLK has the same shape asthe corresponding pulse of DCLK. The falling edge of BCLK corresponds tothe rising edge of UCLK that microcontroller 231 used to begin drivingthe first bit of programming information onto conductor 233. Thesubsequent first rising edge of BCLK at time T6 causes this first bit ofprogramming information (that was previously set up by mictocontroller231 onto terminal FB 206) to be clocked into BITO (MSB first, forexample) of the non-volatile shift register 204. The system 200 uses thesignal SW to synchronize the shifting of programming information fromATE 201 into integrated circuit 203.

This supplying of a bit of programming data onto FB terminal 206 bymicrocontroller 231 and the subsequent clocking of that bit intonon-volatile shift register 204 occurs bit by bit until all thirty-twobits of shift register 204 have been loaded with corresponding bits ofprogramming information. The shifting in of the last bit occurs on therising edge of BCLK shortly after time T7 in the waveform diagram ofFIG. 10. Counter 236 in the non-volatile shift register 204 counts thenumber of times DCLK transitions high, and on the next rising edge ofDCLK shortly after time T8 counter 236 asserts a signal (designated“N+1” in FIG. 6) high. Assertion of this signal triggers a one-shot 237such that one-shot 237 asserts a program enable signal PREN high.Assertion of signal PREN is illustrated after time T8 in the waveformdiagram of FIG. 10. Assertion of PREN high causes the bits ofprogramming information to be programmed into their respective bits ofthe non-volatile shift register 204. When one-shot 237 times out, PRENtransitions low. In this example, operation continues in program modeuntil the input supply voltage to power supply 202 is removed or tunedoff and the power supply 202 is unpowered. When power is thereafterapplied to power supply 202 to verify operation after programming byATE, or when power supply 202 is used by an end customer, the integratedcircuit 203 starts up in normal mode (signal PM is low and remains low).The power supply 202 therefore does not operate in program mode unlessit is forced to enter program mode by ATE 201.

FIG. 11 is a flowchart of a method 500 of programming a PSR CC/CVcontroller integrated circuit in accordance with one novel aspect. In afirst step (step 501), an assembled application circuit is coupled toautomatic test equipment (ATE). In one example, the assembledapplication circuit is the PSR CC/CV power supply 202 of FIG. 5 and theATE is ATE 201 of FIG. 5.

Next (step 502), the ATE exercises and tests the assembled applicationcircuit and collects test data. In one example, the ATE collects data onhow IOUT changes with VIN, on how IOUT changes with VOUT, and on howVOUT changes with cord resistance.

Next (step 503), software executing in the ATE uses the collected testdata to determine how to program the PSR controller integrated circuitin the assembled application circuit in order to correct for undesiredoutput characteristics of the tested application circuit. In oneexample, this software determines what the values of the thirty-two bitsof programming information shifted into non-volatile shift register 204should be to correct for detected errors in the voltage and currentoutput by power supply 202.

Next (step 504), the ATE drives the FB terminal of the PSR controllerintegrated circuit to five volts such that the PSR controller integratedcircuit begins operating in the program mode.

Next (step 505), the PSR controller switches from using an externalvoltage divider involving RFB1 and RFB2 to using an internal voltagedivider involving resistors R11 and R12. The overall assembledapplication circuit then regulates VOUT to a higher voltage such thatVDD received into the PSR controller integrated circuit increases ordecreases to a programming voltage. In one example, VDD increases fromapproximately 15 volts to approximately 17 volts.

Next (step 506), the ATE serially supplies bits of programminginformation to the PSR controller integrated circuit synchronously withthe signal SW, and the PSR controller shifts the bits into itsnon-volatile shift register synchronously with the signal SW. In oneexample, ATE 201 of FIG. 5 supplies bits of programming information ontothe FB terminal 206 of integrated circuit 203 synchronously with fallingedges of signal SW, and integrated circuit 203 clocks in the bits ofprogramming information synchronously with rising edges of signal SW.

Next (step 507), the PSR controller integrated circuit uses theprogramming voltage (the raised 17 volt voltage VDD) to program theloaded programming information into the bits of the non-volatile shiftregister.

Next (step 508), the power supply is powered off and back on, and isretested to obtain the power supply's output voltage and output currentprofile to verify proper power supply operation after programming.

Next (step 509), the programmed application circuit is decoupled fromthe ATE and the next assembled application circuit to be tested iscoupled to the ATE. Steps 501-509 are repeated automatically and rapidlyunder control of the ATE such that a sequence of many assembledapplication circuits (for example, CC/CV power supplies) is tested andprogrammed.

FIG. 12 is a simplified circuit diagram of one way to realize a bit ofnon-volatile shift register 204. Tunneling transistor 611 is anN-channel transistor having a body that is isolated from the integratedcircuit substrate. The body is isolated so that body can be pulled up tothe programming voltage.

To program a bit of programming information into the non-volatile cellof FIG. 12, a bit of programming information on DIN serial input 600 isshifted into D-type flip-flop 601 on the rising edge of BCLK. BCLK isreceived on clock input 602. Once the bit of programming information ispresent in flip-flop 601, the programming enable signal PREN is pulsedas illustrated in FIG. 10. The programming voltage is therefore suppliedonto conductor 603. If the bit of information stored in flip-flop 601 isa digital logic high, then NOR gate 604, transistor 605 and resistor 606cause the programming voltage to be supplied onto the source-body ofP-channel transistor 607. Also, OR gate 608, transistor 609 and resistor610 cause ground potential to be coupled onto the body-source-drainterminals of tunneling transistor 611. The floating gate of P-channeltransistor 607 is then programmed such that transistor 607 is conductiveand such that the non-volatile cell stores a digital logic high.

If, on the other hand, the bit of information stored in flip-flop 601 isa digital logic low, then NOR gate 604, transistor 605 and resistor 606cause ground potential to be coupled onto the source-body of P-channeltransistor 607. OR gate 608, transistor 609 and resistor 610 cause theprogramming voltage to be supplied onto the body of tunneling transistor611. The floating gate of P-channel transistor 607 is then programmedsuch that transistor 607 is nonconductive and such that the non-volatilecell stores a digital logic low. The programmed values of eachnon-volatile bit are latched into flip-flop 601 at power-up of the PSRCC/CV controller integrated circuit when POR transitions from low tohigh.

Efficiency Variation Compensation:

FIG. 13 is a diagram that represents operation of an actual assembledPSR CC/CV power supply. As VOUT decreases, IOUT is seen to increase. Theoutput voltage and output current points of operation do not follow theideal vertical line 700, but rather follow the dashed line 701. This isbecause as VOUT decreases, efficiency of the power supply increases. Inconstant current mode, the PSR CC/CV controller integrated circuit makesthe switching frequency fs proportional to VOUT. Therefore, as VOUTdecreases, fs decreases. There are, however, switching losses associatedwith switching the power supply, so reducing the switch frequency fsreduces the amount of switching and causes a reduction in switchinglosses, thereby increasing efficiency. As indication by Equation 1below, a change in efficiency η causes proportional a change in IOUT inan ordinary uncorrected PSR power supply.

$\begin{matrix}{{IOUT} = \frac{\frac{1}{2} \cdot \eta \cdot {Lp} \cdot {IP}^{2} \cdot {fs}}{VOUT}} & \left( {{Equ}.\mspace{11mu} 1} \right)\end{matrix}$where Lp is the primary winding inductance and IP is the peak current inthe primary winding in each switching cycle.

FIG. 14 illustrates the efficiency variation compensation circuit 238(CC1) of FIG. 6. The voltage VILM on node 413 sets the peak currentlimit value ILIM which determines IOUT in constant current mode.Decreasing VILIM therefore decreases IOUT. Increasing VILIM thereforeincreases IOUT. The magnitude of VILM is set in part by the resistancesof resistors R3 and R4, and by the reference voltage VREF. The novelefficiency variation compensation circuit 238 works by generating acurrent 702 that decreases in proportion to a decrease in VOUT. Thiscurrent 702 is supplied onto node 413. Therefore if VOUT decreases, thetotal current flowing into node 413 decreases, and the voltage VILIMdeceases, thereby decreasing ILIM and IOUT from what it would otherwisebe. This reduction in IOUT compensates for and corrects for what wouldotherwise be an increase in IOUT as VOUT decreases. Amplifier 703operates to force the voltage across programmable resistor R5 to be VFB.The current flowing across R5 is therefore VFB/R5. This current ismirrored by current mirror 704 to generate the current 702 that is madeto flow into node 413. Accordingly, programming the resistance ofprogrammable resistor R5 allows the amount of efficiency compensation tobe adjusted.

Primary Inductance Variation Compensation:

In accordance with Equation 1 above, IOUT varies with variations inprimary winding inductance. Such variations in primary windinginductance, from manufacturer transformer unit to manufacturedtransformer unit, arise from variations in the transformer manufacturingprocess. Variations in IOUT, which are due to variations in Lp, can becorrected by trimming R4. For example, if Lp varies by +7%, then R4 canbe adjusted down by 2.64% (the square root of seven percent), to bringIOUT back down to the desired nominal value. Programmable resistor R4adjusts VILIM, which sets the peak current, IP, in the primary winding.

VIN Line Voltage Variation Compensation:

In constant current (CC) mode, current limit comparator 412 detects whenthe primary current exceeds the current limit ILIM when switch 400 ison. When the current sense voltage VCS exceeds the current limit voltageVILIM on node 413, comparator 412 trips and outputs a low-to-hightransition that in turn causes control logic 411 to force switch signalSWON low, thereby causing N-channel transistor 400 to be turned off andcausing switch 219 to be turned off. There is, however, a delay in timebetween the time VCS exceeds VILIM and the time when switch 219 isactually turned off and current stops flowing in primary winding 228. Itis assumed that this turn-off propagation is approximately fixed,regardless of the magnitude of the input line voltage VIN. In anordinary PSR CC/CV power supply, the rate of current ramping up in theprimary winding depends on the magnitude of the input line voltage VIN.The rate is roughly given by Equation 2 below.

$\begin{matrix}{\frac{\mathbb{d}I}{\mathbb{d}T} = \frac{VIN}{LP}} & \left( {{Equ}.\mspace{11mu} 2} \right)\end{matrix}$

FIG. 15 shows the ramp up in primary current ILP when switch 219 is onin two conditions. In one condition (represented by dashed line 705) theinput line voltage VIN is relatively high, for example 240 VAC, whereasin the other condition (represented by line 706) VIN is relatively low,for example 100 VAC. As indicated in FIG. 15, if the slope of currentramp up in the primary is steeper, then the primary inductor current ILPwill continue to rise a greater amount during the approximately fixedturn-off time (between the time VCS crosses the current limit voltageVILIM and the time when the switch 219 actually turns off and currentstops flowing in primary winding 228). If the slope of current ramp upin the primary inductor is less steep, then the primary inductor currentILP will continue to rise a smaller amount during the approximatelyfixed turn-off time (between the time VCS crosses the current limitvoltage VILIM and the time when the switch 219 actually turns off andcurrent stops flowing in the primary winding 228). The peak current IPof the power supply therefore varies and this causes the regulatedoutput current IOUT to vary as well. IOUT is seen to vary with the inputline voltage VIN.

In one novel aspect, input voltage variation correction circuit 239(CC2) of FIGS. 6 and 14 operates to compensate for and correct for thisundesirable variation in peak current IP. A current is pulled from node413 so that VILIM is less than it otherwise would be, and this currentis made to increases proportionally with increasing VIN so that theeffect illustrated in FIG. 15 is corrected. As indicated in FIG. 9, whenswitch 219 is conductive the voltage on the auxiliary winding VAUX isnegative. VAUX is approximately (−VIN*(N_(A)/N_(P))). This negative VAUXis voltage—divided by the resistor voltage divider of resistors RFB1 andRFB2 such that a negative voltage, is present on FB terminal 206 duringthe on-time of switch 219. N-channel transistor 707 is diode-connectedand has its source grounded. This causes the source of the otherN-channel transistor 708 to be roughly at ground potential as well. Thenegative voltage on FB terminal 206 causes a current to flow out oftransistor 708 that is roughly equal to −VIN*(N_(A)/N_(P))/RFB1. Thiscurrent is proportional to input line voltage VIN. This current ismirrored by the P-channel current mirror 709. The resulting mirroredcurrent 710 flows across programmable resistor R9 to generate a voltageVR9 that varies proportionally with input line voltage VIN. Amplifier711 operates to force the voltage on node 712 to the voltage on itsnon-inverting input lead. The current 713 flowing through resistor R10is therefore proportional to the input line voltage VIN. This current713 is pulled from node 413 such that it serves to decrease the voltageVILIM on node 413 as VIN increases. Accordingly, if input line voltageVIN increases then the current 713 increases and the VILIM voltage ispulled down more to combat the affect illustrated in FIG. 15.Conversely, if the input line voltage VIN decreases then the current 713decreases and the VILIM voltage is pulled-down less.

VOUT Cord Resistance Compensation:

When a conventional PSR CC/CV power supply is in use, it is coupled viaa cord to the rechargeable battery of the device being charged. Theresistance of the cord may be significant. Moreover, different units ofthe power supply may be intended to charge different types of devices,so the different units of the power supply may have different types ofcords that have different resistances. Despite these differences in cordresistance, all units of the power supply are to operate within theconstant current (CC) and constant voltage (CV) specificationsillustrated in FIGS. 2 and 4. The bigger the resistance of the cord, thesmaller VCORD at the end of the cord will be if the power supply isoutputting current. Moreover, if the current output by the power supplyincreases, the voltage VCORD at the end of the cord decreases. This isundesirable. If IOUT increases, it is desired that VOUT be made toincrease so that VCORD at the end of the cord remains constant, despitechanges in IOUT, when the PSR CC/CV power supply operates in constantvoltage (CV) mode.

The novel cord resistance compensation circuit (CC3) 240 of FIGS. 6 and16 compensates for changes in VCORD due to changes in IOUT. It isrecognized that in a current-mode PWM controller in CV mode, VCOMP isproportional to IOUT when the controller is in regulation. As IOUTincreases, VCOMP increases. Cord resistance compensation circuit (CC3)240 compensates for the increasing IOUT by supplying a current 800 ontonode 407 that raises the voltage VREF′ such that VOUT increases as IOUTincreases. Amplifier 801 converts VCOMP′ into a proportional current802, which is equal to VCOMP′/R7. Current 802 is mirrored by theP-channel mirror 803 to output a current 800. Current 800 is suppliedonto node 407. Resistance of programmable resistor R7 determines theamount of cord resistance compensation for what would otherwise be adecrease in VCORD as IOUT decreases.

Although certain specific embodiments are described above forinstructional purposes, the teachings of this patent document havegeneral applicability and are not limited to the specific embodimentsdescribed above. Conductor 233 can be used to communicate other types ofinformation both from ATE 201 to integrated circuit 203, and fromintegrated circuit 203 to ATE 201. Error information, diagnosticinformation, control information, and error detection codes can becommunicated across conductor 233. In one advantageous aspect, thisinformation is communicated synchronously with respect to the signal SWwhen power supply 202 is operating. Such information can be communicatedduring normal operation of power supply 202 when the power supply is notcoupled to ATE equipment, as well as during testing of power supply 202such as the in-circuit testing described above. Accordingly, variousmodifications, adaptations, and combinations of various features of thedescribed embodiments can be practiced without departing from the scopeof the invention as set forth in the claims.

1. An integrated circuit comprising: a primary-side regulation constantcurrent/constant voltage (PSR CC/CV) controller that regulates an outputvoltage (VOUT) of switching power supply in a constant voltage (CV) modesuch that the output voltage is regulated to a regulated voltage value,and that regulates an output current (IOUT) of the switching powersupply in a constant current (CC) mode such that the output current isregulated to a regulated current value; and a non-volatile shiftregister that stores a first value, wherein the first value is a factorin determining the regulated voltage value.
 2. The integrated circuit ofclaim 1, wherein the integrated circuit has four and only fourterminals.
 3. The integrated circuit of claim 1, wherein thenon-volatile shift register stores a second value, and wherein thesecond value is a factor in determining the regulated current value. 4.The integrated circuit of claim 3, wherein the integrated circuitincludes a primary inductance variation compensation circuit, andwherein the second value sets the primary inductance variationcompensation circuit.
 5. The integrated circuit of claim 1, wherein thenon-volatile shift register comprises a plurality of non-volatilestorage bits, wherein the first value can be serially shifted into theintegrated circuit and into the non-volatile shift register.
 6. Theintegrated circuit of claim 1, wherein the PSR CC/CV controller isoperable in a normal mode and in a program mode, wherein in the normalmode the PSR CC/CV controller regulates the output voltage in theconstant voltage mode such that the output voltage is regulated to theregulated voltage value, whereas in the program mode the PSR CC/CVcontroller regulates the output voltage in the constant voltage modesuch that the output voltage is regulated to a voltage different thanthe regulated voltage value.
 7. The integrated circuit of claim 6,wherein the PSR CC/CV controller includes a line input voltage variationcompensation circuit.
 8. A primary-side regulation constantcurrent/constant voltage (PSR CC/CV) controller integrated circuit thatis operable in a constant voltage (CV) mode and in a constant current(CC) mode, wherein the PSR CC/CV controller stores a first value and asecond value in a non-volatile shift register that is part of the PSRCC/CV controller integrated circuit, wherein the first value is a factorin determining a voltage at which the PSR CC/CV controller integratedcircuit regulates a power supply output voltage in the CV mode, andwherein the second value is a factor in determining a current at whichthe PSR CC/CV controller integrated circuit regulates a power supplyoutput current in the CC mode.
 9. The PSR CC/CV controller integratedcircuit of claim 8, wherein the PSR CC/CV controller integrated circuitis operable in a program mode, wherein in the program mode the PSR CC/CVcontroller integrated circuit shifts in bits of informationsynchronously with a switch signal output by the PSR CC/CV controllerintegrated circuit.
 10. The PSR CC/CV controller integrated circuit ofclaim 8, wherein the PSR CC/CV controller integrated circuit includes acord resistance compensation circuit.
 11. The PSR CC/CV controllerintegrated circuit of claim 8, wherein the PSR CC/CV controllerintegrated circuit includes an efficiency variation compensationcircuit.
 12. The PSR CC/CV controller integrated circuit of claim 8,wherein the PSR CC/CV controller integrated circuit includes a lineinput voltage variation compensation circuit.
 13. The PSR CC/CVcontroller integrated circuit of claim 8, wherein the PSR CC/CVcontroller integrated circuit is operable in a normal mode and a programmode, wherein if the PSR CC/CV controller integrated circuit isoperating in the CV mode and if the PSR CC/CV controller integratedcircuit is switched from operating in the normal mode to the programmode then the voltage at which the PSR CC/CV controller integratedcircuit regulates the power supply output voltage in the CV mode ischanged.
 14. A method comprising: (a) shifting a first value and asecond value into a non-volatile shift register in a primary-sideregulation constant current/constant voltage (PSR CC/CV) controllerintegrated circuit, wherein the first value is usable by the PSR CC/CVcontroller integrated circuit to set a power supply regulated outputvoltage to which the PSR CC/CV controller integrated circuit regulatesin a constant voltage (CV) mode, wherein the second value is usable bythe PSR CC/CV controller integrated circuit to set a power supplyregulated output current to which the PSR CC/CV controller integratedcircuit regulates in a constant current (CC) mode.
 15. The method ofclaim 14, wherein the PSR CC/CV controller integrated circuit is a partof an operating power supply during the shifting of (a).
 16. The methodof claim 14, further comprising: (b) shifting a third value into thenon-volatile shift register, wherein the PSR CC/CV controller integratedcircuit includes an input voltage variation compensation circuit, andwherein the third value is used to set the input voltage variationcompensation circuit.
 17. The method of claim 14, further comprising:(b) causing the PSR CC/CV controller integrated circuit to enter aprogram mode such that the PSR CC/CV controller integrated circuitchanges the power supply regulated output voltage to which the powersupply regulates the power supply output voltage in the constant voltage(CV) mode; and (c) using the changed power supply regulated outputvoltage to program the first and second values into the non-volatileshift register.
 18. The method of claim 16, further comprising: (c)testing a power supply and obtaining therefrom test data, wherein step(c) occurs before steps (a) and (b), wherein the PSR CC/CV controllerintegrated circuit is a part of the power supply; and (d) usingautomatic test equipment (ATE) to determine the third value based atleast in part on the test data, wherein step (d) occurs after step (c)but before steps (a) and (b).
 19. The method of claim 14, furthercomprising: (b) shifting a third value into the non-volatile shiftregister, wherein the PSR CC/CV controller integrated circuit includesan efficiency variation compensation circuit, and wherein the thirdvalue is used to set the efficiency variation compensation circuit. 20.The method of claim 19, further comprising: (c) testing a power supplyand obtaining therefrom test data, wherein step (c) occurs before steps(a) and (b), wherein the PSR CC/CV controller integrated circuit is apart of the power supply; and (d) using automatic test equipment (ATE)to determine the third value based at least in part on the test data,wherein step (d) occurs after step (c) but before steps (a) and (b). 21.The method of claim 14, further comprising: (b) shifting a third valueinto the non-volatile shift register, wherein the PSR CC/CV controllerintegrated circuit includes a cord resistance compensation circuit, andwherein the third value is used to set the cord resistance compensationcircuit.
 22. The method of claim 21, further comprising: (c) testing apower supply and obtaining therefrom test data, wherein step (c) occursbefore steps (a) and (b), wherein the PSR CC/CV controller integratedcircuit is a part of the power supply; and (d) using automatic testequipment (ATE) to determine the third value based at least in part onthe test data, wherein step (d) occurs after step (c) but before steps(a) and (b).
 23. A method comprising: (a) operating a primary-sideregulation (PSR) power supply and obtaining therefrom test data, whereinthe PSR power supply includes an integrated circuit and a transformer,wherein the integrated circuit includes a PSR controller; and (b)programming information into integrated circuit while the PSR powersupply is operating, wherein (b) occurs after the obtaining of the testdata of (a).
 24. The method of claim 23, wherein the integrated circuitis a packaged integrated circuit, and wherein (a) and (b) occur after afinal test of the packaged integrated circuit before the packagedintegrated circuit is assembled with the transformer to form the PSRpower supply.
 25. An integrated circuit comprising: a non-volatilestorage circuit that stores a first value and a second value; and meansfor regulating an output of a primary-side regulation constantcurrent/constant voltage (PSR CC/CV) power supply, wherein the firstvalue is a factor in setting a regulated output voltage at which theoutput is regulated in a constant voltage (CV) mode of the power supply,and wherein the second value is a factor in setting a regulated outputcurrent at which the output is regulated in a constant current (CC) modeof the power supply.
 26. The integrated circuit of claim 25, wherein themeans is also for changing the regulated output voltage when the meansis operating in a program mode, wherein the changed regulated outputvoltage is used to program the non-volatile storage circuit.
 27. Aprimary-side regulation (PSR) controller integrated circuit having anamount of non-volatile rewritable memory, wherein the memory is adaptedto store more than two values taken from the group consisting of: avalue that sets a constant voltage (CV) mode power supply outputvoltage, a value that sets a constant current (CC) mode power supplyoutput current, a value that controls an efficiency variationcompensation circuit, a value that controls a line input voltagevariation compensation circuit, a value that controls a cord resistancecompensation circuit, a value that controls a primary inductancevariation compensation circuit, a value that sets a clock frequencywithin the PSR controller integrated circuit, and a value that sets avoltage reference within the PSR controller integrated circuit.